import wordcloud
import numpy
from PIL import Image
txt = '三连 三连 三连 三连 三连 点赞 点赞 关注 关注 投币 投币 收藏 收藏 评论 弹幕'
image = Image.open('circle.png')
img = numpy.array(image)
image_color = wordcloud.ImageColorGenerator(img)
wc = wordcloud.WordCloud(
    font_path='simhei.ttf',
    mask=img,
    background_color='pink',
    contour_width=5,
    contour_color='black',
    color_func=image_color,
    repeat='True',
    max_words=50
)
wc.generate(txt)
wc.to_file('三连.png')
p = Image.open('三连.png')
p.show()
